namespace NFreeMarker.Template
{
    /**
     * A simple implementation of the <tt>TemplateScalarModel</tt>
     * interface, using a <tt>string</tt>.
     * As of version 2.0 this object is immutable.
     *
     * <p>This class is thread-safe.
     *
     * @version $Id: SimpleScalar.java,v 1.38 2004/09/10 20:50:45 ddekany Exp $
     * @see SimpleSequence
     * @see SimpleHash
     */

    public sealed class SimpleScalar : ITemplateScalarModel //, Serializable
    {
        /**
         * @serial the value of this <tt>SimpleScalar</tt> if it wraps a
         * <tt>string</tt>.
         */
        private readonly string _value;

        /**
         * Constructs a <tt>SimpleScalar</tt> containing a string value.
         * @param value the string value.
         */

        public SimpleScalar(string value)
        {
            _value = value;
        }

        public string GetAsString()
        {
            return _value ?? "";
        }

        public override string ToString()
        {
            return _value;
        }
    }
}